#include "btim.h"
uint32_t sys_tick = 0;
static void _btim_config(void)
{
    BTIM_TimeBaseInitTypeDef BTIM_TimeBaseInitStruct = {0};
    __SYSCTRL_BTIM123_CLK_ENABLE();
    BTIM_TimeBaseInitStruct.BTIM_Mode      = BTIM_MODE_TIMER;
    BTIM_TimeBaseInitStruct.BTIM_Period    = 5999; // 1ms
    BTIM_TimeBaseInitStruct.BTIM_Prescaler = 7;   // 7+1=8分频

    BTIM_TimeBaseInit(CW_BTIM1, &BTIM_TimeBaseInitStruct);
    BTIM_ITConfig(CW_BTIM1, BTIM_IT_UPDATE, ENABLE);
    BTIM_Cmd(CW_BTIM1, ENABLE);
}

/**
  * @brief  Configure the nested vectored interrupt controller.
  * @param  None
  * @retval None
  */
static void _NVIC_Configuration(void)
{
    __disable_irq();
    NVIC_EnableIRQ(BTIM1_IRQn);
    __enable_irq();
}
void btim1_init(void)
{
    _btim_config();
    _NVIC_Configuration();
}
